package com.fox.stock.face.impl;

import com.fox.stock.face.StockCacheFace;
import com.fox.stock.mapper.StockBusinessMapper;
import com.fox.stock.pojo.entity.StockBusiness;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

@Component
public class StockCacheFaceImpl implements StockCacheFace {

    @Autowired
    private StockBusinessMapper stockBusinessMapper;


    @Cacheable(cacheNames = "Stock", key = "'stockCodes'")
    @Override
    public List<String> getAllStockCodeWithPredix() {
        List<String> infos = stockBusinessMapper.getAllStockCode();
        infos = infos.stream().map(code -> code.startsWith("6") ? "sh" + code : "sz" + code).collect(Collectors.toList());
        return infos;
    }

    @Override
    public void updateStockInfoById(StockBusiness info) {

    }
}
